package com.code.leetcode.offer;

import com.code.leetcode.utils.ListNode;

import java.util.List;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/31 16:01
 */
public class The18 {
    public ListNode deleteNode(ListNode head, int val) {
        if (head == null) return null;
        ListNode root = new ListNode(0);
        root.next = head;
        ListNode temp = root;
        while(head != null) {
            if (head.val != val) {
                head = head.next;
                temp = temp.next;
            } else {
                temp.next = head.next;
                break;
            }
        }
        return root.next;
    }
}
